<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/*
 * author	:	Tran Van Thanh
 * email	:	thanhtran@vietnambiz.com
 * date		:	01/09/2011
 */

require_once 'client'.EXT;

class Recruitment extends Client {

	function __construct()
	{
		parent::__construct();		
        $this->load->library(array("form_validation","Message","pagination"));
		$this->load->helper(array('custom_string','form'));
		$this->load->model(array('articles_model','home_model'));	

		$this->data['support'] 				= $this->home_model->get_support();
		$this->data['questions']			= $this->home_model->get_questions(1);
		$this->data['products_best_sales']	= $this->home_model->get_all_products('best_sales',5);
	}
	
	function index($page = 1)
	{		
		$limit		=	8;		
		$offset     = 	($page-1)*$limit;
				
		$result		=	$this->articles_model->get_all_recruitment($limit,$offset);

		$num_rows   =	$result['num_rows'];
		$rows		=	$result['rows'];
		
		$total		=	ceil($num_rows/$limit);			
		
		$url		=	base_url().'tuyen-dung';		
			
		$conf = array(
			'cur_page'			=>	$page,
			'base_url'			=>	$url,
			'total_rows'		=>	$total,
			'cur_page'			=>	$page,			
			'cur_class'			=>	'currentpage',
			'prev_class'		=>	'prevnext',
			'next_class'		=>	'prevnext',
			'next_link'			=>	'Tiếp theo',
			'prev_link'			=>	'Trang trước',
			'show_total'		=>	'no',
			'show_first_last'	=>	'no'
		);
		
		$this->pagination->initialize($conf);
		$this->data['pagnav'] 		= $this->pagination->non_ajax();
		$this->data['page']			= $page;
		$this->data['num_rows'] 	= $num_rows;
		$this->data['total_page'] 	= $total;
		
		$this->data['all_articles']			= $rows;			
		
		//meta tag
	    $this->data['title'] 			= get_title('[TITLE]',"Tuyển dụng");
	    $this->data['description'] 		= get_description('[DESCRIPTION]',"Tuyển dụng");
		$this->data['keywords'] 		= get_keywords('[KEYWORDS]',"Tuyển dụng");	    
		//end meta tag
					
		$this->data['tpl_file']		=	'recruitment/index';
		$this->load->view('layout/default',$this->data);
	}	
	
	function detail($id_articles = null, $title_link = null)
	{
		$articles_info					= $this->articles_model->get_articles_detail($id_articles);
		$this->data['articles_info']  	= $articles_info;
		$this->data['articles_orther']	= $this->articles_model->get_articles_orther_recruitment($id_articles);
		
		//meta tag
	    $this->data['title'] 			= get_title('[TITLE]',$articles_info == null ? "" : $articles_info[0]->title);
	    $this->data['description'] 		= get_description('[DESCRIPTION]',$articles_info == null ? "" : $articles_info[0]->title);
		$this->data['keywords'] 		= get_keywords('[KEYWORDS]',$articles_info == null ? "" : $articles_info[0]->title);	    
		//end meta tag
		
		$this->data['tpl_file']		=	'recruitment/detail';
		$this->load->view('layout/default',$this->data);
	} 
}